package cn.clq.ssmshiro.controller;

import cn.clq.ssmshiro.pojo.User;
import cn.clq.ssmshiro.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping(value = "/SubLogin",produces = "application/json;charset=UTF-8")
    public String login(User user){
        System.out.println("into login!");
        boolean flag = userService.checkUser(user);
        if(flag){
            return "index";
        }
        return "/login.html";
    }

    @RequestMapping("/logout")
    @ResponseBody
    public String logout(){
        boolean flag = userService.logout();
        if(flag)
            return "注销成功";
        else
            return "注销失败";
    }

}
